-- local LoginModel     = require("script.oyeahgame.login.model.LoginModel")
local IProvider      = require("script.sdk.provider.IProvider")
local ProviderPlayer = class("ProviderPlayer", IProvider)

function ProviderPlayer:isShowRegister()
    return true
end
function ProviderPlayer:callStaticMethod(methodName,args)
    if methodName == "initSDK" then
        args.listener()
    elseif methodName=="quicklogin" then
        LoginModel.createUser(LoginModel.createUserName(),function(result)
            if result.result then
                local info = string.split(result.info,",")
                -- args.listener({logintype=16, LOGININFO='{"username":"400088117","sessionid":"E7NAwLtpUxuVP8CjNvpariv22EYDQWFgHdDL73VcgxMH8CqIPPM4dSvwmE8RrNhaxNlxfRL90yH8\nnxlZDSk2XuxKoXCAR6zXckq2JX/RBKsyXlVAj4loIC5MIUpsaiYLm9tfEmdigJwQNJQZAbWa6yvc\nxOG6/d+V1M0du9POxSJIkZBTP3bxq3cYxsgxCKKSGjheVWeJDBujFd0XVpHMWp0BN4oFzWR68pNl\npq3SwvlvpruZmvazDLdfLobub6Z+1JuTVjFLawlJdfs7gtne++tTdSWNSpL9zONordy+R1qZRpPy\n5sfEj/iOBc91jm+w29clAqPzrE0YhMz+uS3grw=="}'})
                args.listener({logintype=1, LOGININFO='{"isLogined":true, "username":"'..info[1]..'","sessionid":"'..info[2]..'"}'})
            end
        end)
    elseif methodName == "canQuickLogin" then
        return "true"
    elseif methodName == "login" then
        -- args.listener({result="true",
        --     userId="cpd10725028",
        --     token="MmRlMFZnTlJDUUJTVTFRSUFnb0VCZ2hTWGxwVlh3RUJBQUVOQkFBSEJBRlRDd3BWVlZjS1VsWUJVUTlUQlZ3QUFRSUtCbE1EWGdJRlZ3RUFWaHBPR0FjQUFnQlZWMThGQmxGV0RnUlFVbHRlVkF4V1ZWNWRVUVVDQkZZSFVsUlJIVTVQVndkVURnQlNVMWNQQkE="})
        l_command.createModule("LoginInput")
    elseif methodName == "register" then
        l_command.createModule("LoginRegister")
    elseif methodName == "charge" then
       l_loadingView:removeLoading()
       l_command.createModule("Globalyesorno",{dis="确定充值"..args.productName.."？", callback=function()
                args.listener({result="true",productName=args.productName})
            end,
            cancelback = function()
                args.listener({result="false",productName=args.productName})
            end
    })

    elseif methodName == "logout" then
       
        l_command.createModule("AlertPanel",{msg="确定注销并返回登陆界面？", callback=function(arg)
            if arg then
                args.listener()
            end
        end})
    elseif methodName=="getPlatform" then
        return "20"
    elseif methodName=="getIsLogined" then
        local userDefault = cc.UserDefault:getInstance()
        local uname = userDefault:getStringForKey("uname", "")
        local password = userDefault:getStringForKey("password", "")
        return uname~="" and password~="" and "true"
    end
    
end
return ProviderPlayer
